#include "Node.h"

Node::Node(/* args */)
{
    _scale = glm::vec3(1.0f, 1.0f, 1.0f);
}

Node::~Node()
{
}

glm::vec3 Node::getPosition() const
{
    return _position;
}
void Node::setPosition(glm::vec3 value)
{
    _position = value;
}

glm::vec3 Node::getScale() const
{
    return _scale;
}
void Node::setScale(glm::vec3 value)
{
    _scale = value;
}

glm::vec3 Node::getRotation() const
{
    return _rotation;
}
void Node::setRotation(glm::vec3 value)
{
    _rotation = value;
}

glm::mat4 Node::getMatrix() const
{
    glm::mat4 mat(1.0f);
    mat = glm::rotate(mat, glm::radians(_rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
    mat = glm::rotate(mat, glm::radians(_rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
    mat = glm::rotate(mat, glm::radians(_rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
    mat = glm::scale(mat, _scale);
    mat = glm::translate(mat, _position);
    return mat;
}

//===========子节点=====================
std::vector<Node *> Node::getChildren() const
{
    return _children;
}
void Node::addChild(Node *node)
{
    _children.push_back(node);
}
void Node::render()
{
    int size = _children.size();
    for (int i = 0; i < size; ++i)
    {
        Node *n = _children[i];
        n->render();
    }
}